package com.ruoyi.chat.config;

import com.ruoyi.chat.store.MongoChatMemoryStore;
import dev.langchain4j.community.model.dashscope.QwenStreamingChatModel;
import dev.langchain4j.memory.chat.ChatMemoryProvider;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author WaKy
 * @version 1.0
 * @create 2025/5/19 14 55
 */
@Configuration
public class SeparateChatAssistantConfig {

    @Autowired
    private MongoChatMemoryStore mongoChatMemoryStore;

    @Bean("chatMemoryProvider")
    public ChatMemoryProvider chatMemoryProvider() {
        return memoryId -> MessageWindowChatMemory
                .builder()
                .id(memoryId)
                // 指定chatMemoryStore的实现类
                .maxMessages(20)
                .chatMemoryStore(mongoChatMemoryStore)
                .build();
    }

    // 暂时不知道怎么使用DeepSeek,会报错。
    /*@Bean("openAiStreamingChatModel")
    public OpenAiStreamingChatModel openAiStreamingChatModel() {
        return OpenAiStreamingChatModel.builder()
                .apiKey("sk-07e7fec88b09484cb115dc585c677f45")
                .baseUrl("https://api.deepseek.com")
                .build();
    }*/

    @Bean("qwenStreamingChatModel")
    public QwenStreamingChatModel qwenStreamingChatModel() {
        return QwenStreamingChatModel.builder()
                .apiKey("sk-382951e24f5e422a90a4e0f5d1b3a3aa")
                .modelName("deepseek-v3")
                .temperature(0.6F)
                .build();
    }

    /*@Bean("ollamaStreamingChatModel")
    public OpenAiStreamingChatModel ollamaStreamingChatModel() {
        return OpenAiStreamingChatModel.builder()
                .apiKey("sk-07e7fec88b09484cb115dc585c677f45")
                .baseUrl("https://api.deepseek.com")
                .build();
    }*/
}
